
function ajaxTable(){
    //console.log('start')
    $.ajax({
            type:"POST",
            dataType: "json",
            url:"{:url('Client/json')}",
            data:'clients',
            success:function(data){
                //console.log(data[0].cid+123)
                createShowingTable(data);
            },
            error:function () {
                console.log('error')
            }
        }
    );
}
//动态的创建一个table
function createShowingTable(data) {

    var tableStr = "<table id='fixedTable' class='table table-striped jambo_table table-hover' data-toggle='table'>";
    tableStr = tableStr
        + `<thead>
                <tr>
                    <th><span>客户编号</span></th>
                    <th><span>客户名称</span></th>
                    <th><span>所属国家</span></th>
                    <th><span>操作</span></th>
                </tr>
            </thead>`;
    var len = data.length;
    for ( var i = 0; i < len; i++) {
        tableStr = tableStr +
        '<tbody>'+
            '<tr>'+
                '<td>'+data[i].cid+'</td>'+
                '<td>'+data[i].client+'</td>'+
                '<td>'+data[i].state+'</td>'+
                '<td>'+
                    '<a href="#" class="table-link" onclick=edit("'+data[i].cid+'") title="修改">'+
                        '<span class="fa-stack">'+
                            '<i class="fa fa-square fa-stack-2x"></i>'+
                            '<i class="fa fa-pencil fa-stack-1x fa-inverse"></i>'+
                        '</span>'+
                    '</a>'+
                    '<a href="#" class="table-link danger class-del" onclick=del("'+data[i].cid+'") title="删除">'+
                        '<span class="fa-stack">'+
                            '<i class="fa fa-square fa-stack-2x"></i>'+
                            '<i class="fa fa-trash-o fa-stack-1x fa-inverse"></i>'+
                        '</span>'+
                    '</a>'+
                   
                '</td>'+
            '</tr>'+

        '</tbody>';
    }

    tableStr = tableStr + "</table>";
    //添加到div中
    $("#fixedTable").html(tableStr);
}